import os, sys

path = '/home/leo/workspace/data_set/beibeiPoliceOffice/2019-06-20/'


from multiprocessing import cpu_count
import threadpool

def thread_pool(enter_func,param_list):
    pool = threadpool.ThreadPool(int(cpu_count()/2))
    requests = threadpool.makeRequests(enter_func, param_list)
    [pool.putRequest(req) for req in requests]
    pool.wait()

def doExtra(cmd):
    os.system(cmd)

if __name__ == '__main__':
    files = []
    param_list= []
    for file in os.listdir(path):
        if os.path.splitext(file)[1] in [".mp4", ".avi"]:
            files.append(os.path.join(path, file))

    print(files)
    for file in files:
        cmd = "../bin/cv_extra_video "+file+ " 15"
        param_list.append(cmd)
    thread_pool(doExtra,param_list)
